package vg.services.graph_view_manager.realization.graph_view.smart_graph_view.realization.actions;

import vg.services.graph_view_manager.interfaces.graph_view.IGraphRenderer;

import javax.swing.*;

/**
 * Adds and removes item from graph view.
 *
 * @author Timur Zolotuhin (e-mail: tzolotuhin@gmail.com)
 */
public class PopupMenuItemAction extends DefaultActionAdapter {
    // add item action
    public static final int ADD_ITEM_ACTION = 1;
    // remove item action
    public static final int REMOVE_ITEM_ACTION = 2;

    // Main data
    private int action;
    private JMenuItem item;

    public PopupMenuItemAction(int action, JMenuItem item) {
        super("add/remove menu item action");

        this.action = action;
        this.item = item;
    }

    @Override
    public void action(IGraphRenderer graphRenderer) {
        switch (action) {
            case ADD_ITEM_ACTION:
                graphRenderer.addPopupMenuItem(item);
                break;

            case REMOVE_ITEM_ACTION:
                graphRenderer.removePopupMenuItem(item);
                break;

            default:
                break;
        }
    }
}
